﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ElementumForever.Interfaces;
using Microsoft.Xna.Framework.Input;

namespace ElementumForever.Decorators
{
    abstract class BaseDecorator : BaseEntity
    {
        protected BaseEntity _component;

        public BaseDecorator(BaseEntity component)
            : base()
        {
            OnCreat();
            this._component = component;
        }

        public override void OnAttach(IEntity parent)
        {
            base.OnAttach(parent);
            this._component.OnAttach(parent);
        }

        public override void OnDetach()
        {
            base.OnDetach();
            this._component.OnDetach();
        }

        public override string Name
        {
            get
            {
                return _component.Name;
            }
            set
            {
                _component.Name = value;
            }
        }

        public override float X
        {
            get
            {
                return _component.X;
            }
            set
            {
                _component.X = value;
            }
        }

        public override float Y
        {
            get
            {
                return _component.Y;
            }
            set
            {
                _component.Y = value;
            }
        }

        public override float Width
        {
            get
            {
                return _component.Width;
            }
            set
            {
                _component.Width = value;
            }
        }

        public override float Height
        {
            get
            {
                return _component.Height;
            }
            set
            {
                _component.Height = value;
            }
        }

        public override float OriginX
        {
            get
            {
                return _component.OriginX;
            }
            set
            {
                _component.OriginX = value;
            }
        }

        public override float OriginY
        {
            get
            {
                return _component.OriginY;
            }
            set
            {
                _component.OriginY = value;
            }
        }

        public override IEntity Parent
        {
            get
            {
                return _component.Parent;
            }
        }

        public override float Alpha
        {
            get
            {
                return _component.Alpha;
            }
            set
            {
                _component.Alpha = value;
            }
        }

        public override Microsoft.Xna.Framework.Color Color
        {
            get
            {
                return _component.Color;
            }
            set
            {
                _component.Color = value;
            }
        }

        public override float LayerDepth
        {
            get
            {
                return _component.LayerDepth;
            }
            set
            {
                _component.LayerDepth = value;
            }
        }

        public override Enums.EObjectClass ObjectClass
        {
            get
            {
                return _component.ObjectClass;
            }
            set
            {
                _component.ObjectClass = value;
            }
        }


        public override Microsoft.Xna.Framework.Matrix Projection
        {
            get
            {
                return _component.Projection;
            }
        }

        public override Microsoft.Xna.Framework.Matrix Unprojection
        {
            get
            {
                return _component.Unprojection;
            }
        }

        public override float Rotation
        {
            get
            {
                return _component.Rotation;
            }
            set
            {
                _component.Rotation = value;
            }
        }

        public override float ScaleX
        {
            get
            {
                return _component.ScaleX;
            }
            set
            {
                _component.ScaleX = value;
            }
        }

        public override float ScaleY
        {
            get
            {
                return _component.ScaleY;
            }
            set
            {
                _component.ScaleY = value;
            }
        }

        public override bool Visiable
        {
            get
            {
                return _component.Visiable;
            }
            set
            {
                _component.Visiable = value;
            }
        }

        public BaseEntity Component
        {
            get
            {
                return _component;
            }
        }

        public override void Dispose()
        {
            _component.Dispose();
        }

        public override void OnUpdate(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.OnUpdate(gameTime);
            _component.OnUpdate(gameTime);
        }

        //public override void OnDraw(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
        //{
        //    //_component.OnDraw(gameTime, spriteBatch);
        //    base.OnDraw(gameTime, spriteBatch);  
        //}

        protected override void UpdateTransform()
        {
            base.UpdateTransform();
            _projectionMatrix = _component.Projection;
        }

        public override IEntity Clone()
        {
            return _component.Clone();
        }

    }
}
